package com.pos.cashier.emp.service;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.pos.cashier.basic.dao.DaoSupport;
import com.pos.cashier.basic.entity.Page;
import com.pos.cashier.basic.util.PageData; 
import com.pos.cashier.emp.bean.Employee;
@Service("employeeService")
public class EmployeeService {

		@Resource(name = "daoSupport")
		private DaoSupport dao;
		
		//======================================================================================
		
		
		// 通过id获取数据
		
		public PageData findByUiId(PageData pd)throws Exception{
			return (PageData)dao.findForObject("EmpMapper.findById", pd);
		}
		
		//新增用户
		
		public void save(Employee employee)throws Exception{
			dao.save("EmpMapper.save", employee);
		}
		
		
		 //删除
		
		public void delete(String id)throws Exception{
			dao.delete("EmpMapper.delete	", id);
		}
		
		
		// 修改
		
		public void update(Employee employee)throws Exception{
			dao.update("EmpMapper.edit", employee);
		}
		

		
		//批量删除用户
		
		public void deleteAllU(String[] USER_IDS)throws Exception{
			dao.delete("EmpMapper.deleteAll", USER_IDS);
		}
		
		//用户列表(全部)
		
		@SuppressWarnings("unchecked")
		public List<PageData> listAllUser(PageData pd)throws Exception{
			return (List<PageData>) dao.findForList("EmpMapper.listAll", pd);
		}
		
		
		//用户列表(用户组)
		
		@SuppressWarnings("unchecked")
		public List<PageData> listPdPageUser(Page page)throws Exception{
			return (List<PageData>) dao.findForList("EmpMapper.datalistPage", page);
		}
		
		
		// 登录判断
		
		public PageData getUserByNameAndPwd(PageData pd)throws Exception{
			return (PageData)dao.findForObject("AppuserMapper.getUserInfo", pd);
		}
		
		// 跟新登录时间
		
		public void updateLastLogin(PageData pd)throws Exception{
			dao.update("AppuserMapper.updateLastLogin", pd);
		}
		//======================================================================================
		

}
